import { Controller, Get, Post, Body, Param, Delete, Put, Query } from '@nestjs/common';
import { SpecsType_Service } from './specsType.service';
import { SpecsType_Create_Dto, SpecsType_Update_Dto } from './assets/specsType.dto';
import { SpecsType_FindByPage_Dto } from './assets/specsType.dto';
import { ApiParam, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { util_Index_ReturnContent } from '@/common/util/index';

@Controller('/adm/specsType')
@ApiTags('specsType 规格属性类别')
export class SpecsType_Controller {
  constructor(private readonly specsType_Service: SpecsType_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
    //apiKey: '/adm/specsType/add Post',
  })
  async specsType_Create(@Body() body: SpecsType_Create_Dto) {
    return util_Index_ReturnContent(await this.specsType_Service.specsType_Create(body));
  }

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
    //apiKey: '/adm/specsType/list Get',
  })
  async specsType_FindAll(@Query() query: SpecsType_FindByPage_Dto) {
    return util_Index_ReturnContent(await this.specsType_Service.specsType_FindAll(query));
  }

  @Get('/platFormId/:platFormId')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
    summary: '通过商品Id获取对应的规格属性类别和规格属性',
    //apiKey: '/adm/specsType/platFormId/:platFormId Get',
  })
  @ApiParam({
    name: 'platFormId',
    description: '商品ID',
    required: true,
    type: String,
  })
  async specsType_FindByPlatFormId(@Param('platFormId') platFormId: string) {
    return util_Index_ReturnContent(
      await this.specsType_Service.specsType_FindByPlatFormId(+platFormId),
    );
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    //apiKey: '/adm/specsType/update Put',
  })
  async specsType_Update(@Body() body: SpecsType_Update_Dto) {
    return util_Index_ReturnContent(await this.specsType_Service.specsType_Update(body));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
    //apiKey: '/adm/specsType/delete/:id Delete',
  })
  async specsType_Remove(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.specsType_Service.specsType_Remove(+id));
  }
}
